package demo6;

public class Test {

    public static void drawMap(Shape shape) {
        shape.draw();
    }


    public static void main(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        Shape[] shapes = {rect,cycle,flower};  //向上转型

        for(Shape shape : shapes) {
            shape.draw();
        }
    }

    public static void main1(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        drawMap(rect);

        drawMap(cycle);

        drawMap(flower);
    }
}
